<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="strScriptName" select="/Page/script_name"/>
	<xsl:template match="Pager">
		<xsl:variable name="intCurentPage" select="CurentPage"/>
		<xsl:variable name="intNumberOfPages" select="NumberOfPages"/>
		<xsl:variable name="intStartPage" select="StartPage"/>
		<xsl:variable name="RowsCount" select="RowsCount"/>
		<xsl:variable name="QSP" select="QSP"/>
		<xsl:variable name="qs" select="//page/script_qs_t"/>	
		
		<table cellspacing="0" cellpadding="0" align="center">
			<tr>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="1"/>
					<xsl:with-param name="test" select="$intStartPage &gt; 1"/>
					<xsl:with-param name="title" select="'&#160;&lt;&lt;&lt;&#160;'"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intCurentPage - 1"/>
					<xsl:with-param name="test" select="$intCurentPage &gt; 1"/>
					<xsl:with-param name="title" select="'&#160;&lt;&#160;'"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 1"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 1"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 2"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 2"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 3"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 3"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 4"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 4"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 5"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 5"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 6"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 6"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 7"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 7"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 8"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 8"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intStartPage + 9"/>
					<xsl:with-param name="test" select="$intCurentPage != $intStartPage + 9"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intCurentPage + 1"/>
					<xsl:with-param name="test" select="$intCurentPage &lt; $intNumberOfPages"/>
					<xsl:with-param name="title" select="'&#160;&gt;&#160;'"/>
				</xsl:call-template>
				<xsl:call-template name="pager_item">
					<xsl:with-param name="page_num" select="$intNumberOfPages"/>
					<xsl:with-param name="test" select="$intStartPage + 9 &lt; $intNumberOfPages"/>
					<xsl:with-param name="title" select="'&#160;&gt;&gt;&gt;&#160;'"/>
				</xsl:call-template>
				<td width="10" align="center" class="titleblack">
					&#160;&#160;&#160;&#160;&#160;Records&#160;count:&#160;<xsl:value-of select="$RowsCount"/>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="Pager/form">
		<SCRIPT LANGUAGE="javascript">
			function SetParam(pname, value) {
				var frm = document.forms['<xsl:value-of select="@name"/>'];
				var e = frm.elements[pname]
				if (typeof(e.length) == 'undefined')
					e.value = value;
				else
					e[0].value = value;
				frm.submit();
			}		
		
			function PagerLink(val1, val2, strScriptName) {
				var i,j;
				var str1, str2;
				i=0;
				j=0;
 				str1 = val1;
				str2 = "main.asp?-"+ strScriptName +"-&amp;";

				var substr1, substr2, substr;
				substr = "";
				substr1 = "";
				substr2 = "";
				i = str1.indexOf("PN=");
				if (i==-1) {
					substr1 = str1.substring(0, str1.lenght);
					location.replace(str2 + str1 + "&amp;PN=" + val2)
				} else {
					substr1 = str1.substring(0,i);
					j = str1.indexOf("&amp;",i);
					substr2 = str1.substring(j, str1.length);
					location.replace(str2 + substr1 + "PN=" + val2 + substr2 )
				}
			}
		</SCRIPT>
		<xsl:copy-of select="."/>
	</xsl:template>

	<xsl:template name="pager_item">
		<xsl:param name="page_num" select="0"/>
		<xsl:param name="test"/>
		<xsl:param name="title" select="concat('&#160;',$page_num,'&#160;')"/>
		<td width="30" align="center">
			<xsl:if test="($page_num &lt;= NumberOfPages) or not($test)">
				<a class="linkbold">
					<xsl:if test="$test">
						<xsl:attribute name="href">
							javascript:PagerLink('<xsl:value-of select="//page/script_qs"/>',<xsl:value-of select="$page_num"/>, '<xsl:value-of select="//page/page_id"/>' + '.asp')
 						</xsl:attribute>
					</xsl:if>
					<font color="{$color_main_first1}"><xsl:copy-of select="$title"/>
				</font></a>
 			</xsl:if>
		</td>
	</xsl:template>
</xsl:stylesheet>


